//
// Created by ashCheng on 2023/2/1.
// 1.6
#include <iostream>
#include <string>

#include "Sales_data.h"

int main() {
  Sales_data total;
  double total_price;
  if (std::cin >> total.bookNo >> total.units_sold >> total_price) {
    total.CalcRevenue(total_price);
    Sales_data trans;
    double trans_price;
    while (std::cin >> trans.bookNo >> trans.units_sold >> trans_price) {
      trans.CalcRevenue(trans_price);
      if (total.bookNo == trans.bookNo) {
        total.AddData(trans);
      } else {
        total.Print();
        total.SetData(trans);
      }
    }
    total.Print();
  } else {
    std::cerr << "No data?!" << std::endl;
    return -1;
  }
  return 0;
}